import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
// /my = / + my
// /qa = / + qa
// /my
// /qa
const routes = [
  { path: '/login', component: () => import('@/views/login') },
  {
    path: '/',
    // name: '/',
    component: () => import('@/views/layout'),
    children: [
      { path: '', name: 'home', component: () => import('@/views/home') },
      { path: 'my', name: 'my', component: () => import('@/views/my') },
      { path: 'qa', name: 'qa', component: () => import('@/views/qa') },
      { path: 'video', name: 'video', component: () => import('@/views/video') }
    ]
  },
  { path: '/search', component: () => import('@/views/search') },
  // 给路由起名字有什么好处？ 路径将来变了，我们不用在一堆组件中找到用到这个路由的地方全部改掉，因为名字只要没变就行了
  { path: '/article/:articleId', name: 'article', component: () => import('@/views/article'), props: true },
  { path: '/user/profile', name: 'user_profile', component: () => import('@/views/user-profile') }
]

const router = new VueRouter({
  routes
})

export default router

// var n = 100
// function fn () {
//   console.log(n)
// }

// fn()
